package com.cheng.admin.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author 起凡
 * @since 2022-01-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("pl_order")
public class Order implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    private Long id;

    /**
     * 总价格(优惠后的)
     */
    private BigDecimal finalPrice;

    /**
     * 优惠券优惠的价格
     */
    private BigDecimal couponPrice;

    /**
     * 商品价格(原价)
     */
    private BigDecimal originPrice;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 是否需要发票
     */
    private Boolean needReceipt;

    /**
     * 订单状态
     */
    private Integer orderStatus;

    private String orderNo;

    /**
     * 支付方式返回的交易号
     */
    private String payOrderNo;

    /**
     * 支付方式0-微信
     */
    private Integer paymentMethod;

    /**
     * 支付时间
     */
    private LocalDateTime paymentTime;

    /**
     * 订单详情
     */
    private String priceDetail;

    /**
     * 发件地址id
     */
    @NotNull(message = "发件地址不能为空")
    @Min(value = 1, message = "发件地址不能为空")
    private Long fromAddressId;

    /**
     * 目标地址id
     */
    @NotNull(message = "收件地址不能为空")
    @Min(value = 1, message = "收件地址不能为空")
    private Long toAddressId;

    /**
     * 优惠券id
     */
    private Long couponId;

    /**
     * 寄信订单 寄明信片订单 寄商品订单
     */
    @NotNull(message = "订单类型不能为空")
    private String type;

    /**
     * 备注
     */
    private String remark;
    /**
     * 物流单号
     */
    private String logisticsNo;

    @NotNull(message = "快递不能为空")
    @Min(value = 1, message = "快递不能为空")

    private Long deliveryId;


    private BigDecimal deliveryPrice;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 完成时间
     */
    private LocalDateTime completeTime;

    /**
     * 删除标志 true/false 删除/未删除
     */
    @TableLogic
    private Boolean deleted;
    // 如果订单类型是 寄明信片
    @TableField(exist = false)
    PostcardOrder postcardOrder;
    // 如果订单类型是 寄信
    @TableField(exist = false)
    PostPictureOrder postPictureOrder;
    // 如果订单类型是 商品订单
    @TableField(exist = false)
    List<OrderProduct> orderProducts;

    @TableField(exist = false)
    private Address address;
    @TableField(exist = false)
    private Address fromAddress;
    @TableField(exist = false)
    private Delivery delivery;
    @TableField(exist = false)
    private Coupon coupon;

}
